package com.liziba.trend.service;

import cn.hutool.core.collection.CollUtil;
import com.liziba.trend.api.Index;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: trend
 * @description: 指数代码数据获取service
 * @author: liziba
 * @date: 2021-02-03 10:45
 */

@Service
@CacheConfig(cacheNames = "indexes")
public class IndexService {

    private List<Index> indexes;

    /**
     * 缓存获取指示代码数据，缓存无数据则返回"无效指数代码"
     * @return
     */
    @Cacheable(key = "'all_codes'")
    public List<Index> getIndexes() throws Exception {
        Index index = new Index( "000000", "无效指数代码");
        return CollUtil.toList(index);
    }
}
